<?php
if(!defined('ADMINPX') || !defined('ADMIN')) {
	exit('Access Denied');
}
$time15=strtotime(date("Y-m-d H:i:s",strtotime(" +15 minute")));
$value= daddsla_add($_POST['username']);
$pwss = user_mm(daddsla_add($_POST['userpass']));
if($_GET[act] == 'login'){
	  if(!$value or !$pwss ){
    ?>
		        不能为空！<br/><a href="admin.php?action=login">返回登陆</a>
		        <meta http-equiv=refresh content="3;url=admin.php?action=login">
	  <?php }else if( Bingz_yzm($_POST[bzyzm]) ){
    ?>
		        验证码出错！<br/><a href="admin.php?action=login">返回登陆</a>
		        <meta http-equiv=refresh content="3;url=admin.php?action=login">
	  <?php }else if($waw=$db->get_one('user'," `pass` = '$pwss' AND `uid` ='$value' " ,'')){
	      if($db->get_one('user_qxz',"`id` ='$waw[user_qx]' and `qxid` = '10'" ,'')){
		       $ip_dz=ip_address($ip);
           setcookie('admin_pwss',$waw[pwss]);
           setcookie('admin_time',$time15);
           setcookie('admin_ip',$ip);
           $url_a=authcode($_COOKIE['adminurl'],'DECODE');
           if(preg_match('/login/',$url_a)){
           	$url_a='admin.php?';
           }
           setcookie('adminurl','');
           $userts  =$db->get_one('user_dl'," `type` ='1' AND `uid` ='$waw[uid]' ORDER BY `id` DESC LIMIT 0 , 1 ",'');
           if(!$userts[time_a]){
           	  $forum_sj='第一次登陆';//时间
           }else{
           	  $forum_sj=Bingz_time_f($userts[time_a]);//时间
           }
		       $db->insert('user_dl',array('id' => 'NULL','type' => '1','uid' => $waw[uid],'uip' => $ip,'uip_dz' => $ip_dz,'zhuangt' => '成功','time_a' => $time));           
    ?>
		        登录成功<br/>
		        上次登陆：<?php echo $forum_sj;?><br/>
		        <a href="<?php echo $url_a;?>">进入上次页面</a><br/>
		        <a href="admin.php?">进入管理中心</a>
		        <meta http-equiv=refresh content="10;url=<?php echo $url_a;?>">
	  <?php
	      }else{
	  ?>
		        登录失败<br/><a href="admin.php?action=login">返回登陆</a>
		        <meta http-equiv=refresh content="3;url=admin.php?action=login">
    <?php 
        }
	  }else if($waw=$db->get_one('user'," `pass` = '$pwss' AND `name` ='$value' " ,'')){
	      if($db->get_one('user_qxz',"`id` ='$waw[user_qx]' and `qxid` = '10'" ,'')){
		       $ip_dz=ip_address($ip);
           setcookie('admin_pwss',$waw[pwss]);
           setcookie('admin_time',$time15);
           setcookie('admin_ip',$ip);
           $url_a=authcode($_COOKIE['adminurl'],'DECODE');
           if(preg_match('/login/',$url_a)){
           	$url_a='admin.php?';
           }
           setcookie('adminurl','');
           $userts  =$db->get_one('user_dl'," `type` ='1' AND `uid` =' $waw[uid]' ORDER BY `id` DESC LIMIT 0 , 1 ",'');
           if(!$userts[time_a]){
           	  $forum_sj='第一次登陆';//时间
           }else{
           	  $forum_sj=Bingz_time_f($userts[time_a]);//时间
           }
		       $db->insert('user_dl',array('id' => 'NULL','type' => '1','uid' => $waw[uid],'uip' => $ip,'uip_dz' => $ip_dz,'zhuangt' => '成功','time_a' => $time));
    ?>
		        登录成功<br/>
		        上次登陆：<?php echo $forum_sj;?><br/>
		        <a href="<?php echo $url_a;?>">进入上次页面</a><br/>
		        <a href="admin.php?">进入管理中心</a>
		        <meta http-equiv=refresh content="10;url=<?php echo $url_a;?>">
	  <?php
	      }else{
		       $db->insert('user_dl',array('id' => 'NULL','type' => '1','uid' => $waw[uid],'uip' => $ip,'uip_dz' => $ip_dz,'zhuangt' => '失败','time_a' => $time));
	  ?>
		        登录失败.<br/><a href="admin.php?action=login">返回登陆</a>
		        <meta http-equiv=refresh content="3;url=admin.php?action=login">
    <?php 
        }
    }else{ ?>
		        登录失败<br/>密码错误！<br/><a href="admin.php?action=login">返回登陆</a>
		        <meta http-equiv=refresh content="3;url=admin.php?action=login">
    <?php }
		foot();
    exit;	
}else{ 
	$yzmm=Verification();
	if(!$_COOKIE['adminurl']){
	setcookie('adminurl',authcode($url_b,'ok'));
  }
	?>
    <div class="admin">登陆网站后台</div>
       <form method="POST" action="admin.php?action=login&act=login">
           <div class="admin_a">账　号<br/><input class="text" type="text" name="username" size="20" value="<?php echo $user[name]; ?>"/></div>
           <div class="admin_a">密　码<br/><input class="text" type="password" name="userpass" size="20"/></div>
           <div class="admin_a">验证码<br/><input class="text" type="text" name="bzyzm" size="20"/><div class="Verification"><?php echo $yzmm; ?></div></div>
           <input class="submit" type="submit" value=" 提交 " name="adminpost" />
       </form>
<?php } ?>

